home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 194_01 / expand.c < prev    next >
Text File  |  1985-11-13  |  1KB  |  52 lines

  1. /¬ [EXPAND.C of JUGPDS Vol.17]
  2. *****************************************************************
  3. *                                *
  4. *    Written by  Hakuo Katayose (JUG-CP/M No.179)        *
  5. *            49-114 Kawauchi-Sanjuunin-machi        *
  6. *            Sendai, Miyagi 980                          *
  7. *            Phone: 0222-61-3219                *
  8. *                                *
  9. *    Edited & tested by Y. Monma (JUG-C/M Disk Editor)       * 
  10. *                                *
  11. *****************************************************************
  12. */
  13.  
  14. /*  expand - uncompress standard input */
  15.  
  16. #include "stdio.h"
  17. #include <dio.h>
  18.  
  19. #define    RCODE        127
  20.  
  21. main(argc,argv)
  22. int    argc;
  23. char    *argv[];
  24.  
  25. {
  26.     int    c, code;
  27.  
  28.     dioinit(&argc, argv);
  29.     if (argc < 2)
  30.         error("Usage: expnd <infile >outfile ^Z");
  31.     while ((code = getchar()) != EOF)
  32.         if (code == RCODE) {
  33.             if ((c = getchar()) == EOF)
  34.                 break;
  35.             if ((code = getchar()) == EOF)
  36.                 break;
  37.             code -= '0';
  38.             while (code--)
  39.                 putchar(c);
  40.         } else {
  41.             code -= '0';
  42.             while (code--) {
  43.                 if ((c = getchar()) == EOF)
  44.                     break;
  45.                 putchar(c);
  46.                 }
  47.             if ( c == EOF )
  48.                 break;
  49.             }
  50.     dioflush();
  51. }
  52.